#-*- encoding:utf-8 -*-
import socket
import thread,threading

sockIndex = 1

def connToServer ():
    global sockIndex
    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    conn.connect(("127.0.0.1", 10889))
    #conn.send("hi,I'm NO."+ str(sockIndex))
    print sockIndex
    sockIndex = sockIndex + 1
    while True:
        rev = conn.recv(1024)
        print 'get server msg:' + str(rev)
        break

threads = []
times = 20000
for i in range(0,times):
    t = threading.Thread(target=connToServer())
    threads.append(t)
for i in range(0,times):
    threads[i].start()
for i in range(0,times):
    threads[i].join()


